{extend name="index/base" /}
{block name="style"}{/block}
{block name="body" }
<blockquote class="layui-elem-quote">
	<a href="javascript:location.reload();" class="layui-btn layui-btn-sm"><i class="layui-icon">&#x1002;</i></a>
	<form class="layui-form search" action="" style="display: inline-block;float: right;" _lpchecked="1">
		<div class="layui-input-inline" style="width: 300px;">
			<input type="text" name="date" class="layui-input" id="date" value="{:date('Y-m-d 00:00:00',time())} ~ {:date('Y-m-d 23:59:59',time())}">
		</div>
		<div class="layui-inline">
			<div class="layui-input-inline" style="width: 100px;">
				<select name="pay_status" >
			        <option value="1">支付成功</option>
			        <option value="0">待支付</option>
			    </select>
			</div>
		</div>
		<div class="layui-inline">
			<div class="layui-input-inline">
				<input type="text" name="keyword" placeholder="ID" autocomplete="off" class="layui-input">
			</div>
		</div>
		 <div class="layui-inline">
		 	<div class="layui-input-inline">
		 		<button class="layui-btn layui-btn-sm sbtn" lay-submit="" lay-filter="searchsub" id="search"><i class="layui-icon"></i> 搜索</button>
		 		<button class="layui-btn layui-btn-sm layui-btn-danger"  id="export"><i class="fa fa-file-excel-o" aria-hidden="true"></i> 导出</button>
		 	</div>
		 </div>
	</form>
</blockquote>
<table id="tb1" lay-filter="_tb1"></table>
{/block}

{block name="script"}
<script type="text/html" id="check">
	<input type="checkbox" lay-skin="primary" name="ids[]" class="ids" value="{{ d.id }}">
</script>
<script type="text/html" id="bar">
	<div class="layui-btn-group">
	  <a class="layui-btn layui-btn-xs edit" data-url="{:url('edit')}?ids={{ d.id }}" >编辑</a>
	  <a class="layui-btn layui-btn-xs confirm_del" data-url="{:url('del')}?ids={{ d.id }}" >删除</a>
	</div>
</script>
<script type="text/html" id="uid">
	<span class="layui-text"><a href="javascript:;"  class="show_userinfo"  data-title="【{{d.user_nickname}}】的用户信息" data-url="{:url('user.index/info')}?id={{d.uid}}" >[{{d.uid}}]{{d.user_nickname}}</a></span>
</script>
<script type="text/html" id="pay_item">
	{{# if(d.pay_item==1){ }}
	礼包
	{{# }else if(d.pay_item==2){ }}
	月付会员
	{{# }else if(d.pay_item==3){ }}
	月付vip
	{{# }else if(d.pay_item==4){ }}
	年付分公司
	{{# } }}
</script>
<script>
	layui.use(['tool','laydate'], function() {
		var $ = layui.$,layer = layui.layer, form = layui.form,table = layui.table,tool = layui.tool,laydate=layui.laydate;
		tool.show_userinfo();
		var tableobj = table.render({
			elem:'#tb1',
			url:'{:url('pay_logs')}',
			limit:15,
			limits:[10,15,20,50,100],
			page:true,
			//size:'sm',
			method:'get',
			height:'full-100',
			cols:[[
				//{title:'<input type=checkbox lay-filter=allChoose lay-skin=primary>',fixed:'left',templet:'#check',width:50},
				{title:'ID',field:'id',width:80},
				{title:'用户',field:'user_nickname',templet:'#uid'},
				{title:'支付金额',field:'amount'},
				{title:'购买项目',field:'pay_item',templet:'#pay_item'},
				{title:'支付方式',field:'pay_type_text'},
				{title:'支付状态',field:'pay_status_text'},
				{title:'时间',field:'create_time'},
				{title:'本地单号',field:'out_trade_no'},
				{title:'第三方单号',field:'trade_no'},
				
				//{title:'操作',fixed: 'right', width:150, align:'center', templet: '#bar'}

			]]
		});
		//搜索
		form.on('submit(searchsub)',function(data){
			var fields = $(data.form).serialize();
			tableobj.reload({
				where:data.field
				,page: {curr: 1 }
			});
			return false;
		})
		//日期时间范围
		laydate.render({
		  elem: '#date'
		  ,type: 'datetime'
		  ,range: '~'
		  ,min:'2018-10-01 00:00:00'
		  ,max:'{:date('Y-m-d 23:59:59',time())}'
		});
		//export
		$('#export').click(function(){
			var url = '{:url('export',['type'=>'pay_logs'])}?';
			var ids = $('.ids:checked').serialize();
			var form = $('form').serialize();
			location.href = url+'&'+form+'&'+ids;

			return false;
		});

	});
</script>
{/block}
